import Vue from 'vue'
import VueRouter from 'vue-router'
import IndexView from '../views/IndexView.vue'
import ReserveView from '../views/ReserveView.vue'
import StateView from '../views/StateView.vue'
import HistoryView from '../views/HistoryView.vue'
import SchoolView from '../views/SchoolView.vue'
import LoginView from '../views/LoginView.vue'
import TimeChangeView from '../views/TimeChangeView.vue'
Vue.use(VueRouter)
const routes = [
  
  {
    path: '/login',
    name: 'a',
    component:LoginView,
  },  
   {
    path: '/',
    name: 'f',
    component:IndexView ,
  },  
  {
    path: '/reserve',
    name: 'ReserveView',
    component: ReserveView,
  },  
  {
    path: '/state/:data',
    name: 'StateView',
    component: StateView,
  },  
  {
    path: '/history',
    name: 'd',
    component: HistoryView,
  },  
  {
    path: '/school',
    name: 'e',
    component: SchoolView,
  },  
  {
    path: '/cgtime/:id',
    name: 'TimeChangeView',
    component: TimeChangeView,
  },  
  
]
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach((to, from, next) => {
  // const publicPages = ['/', '/register', '/email', '/resetPwd', '/tel', '/configresetpwd', '/login'];
  // const authRequired = !publicPages.includes(to.path);
  // const loggedIn = localStorage.getItem('TOKEN');
  // if (authRequired && !loggedIn) {
  //   return next('/login');
  // }
  next(); 
});

export default router
